<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
    <title>用户列表信息</title>
    <style>
        ul{
            list-style: none;
        }
        ul li{
            float: left;
        }
    </style>
    <script>
        function goPage(pageSize){
            var available=document.getElementById("available").value;
            var telephone=document.getElementById("telephone").value;
            var deptid=document.getElementById("deptid").value
            window.location.href="${pageContext.request.contextPath}/user/list?pageSize="+pageSize+"&telephone="+telephone+"&dept.id="+deptid+"&available="+available;
        }
    </script>
</head>
<body>
<table>
    <form action="${pageContext.request.contextPath}/user/list" method="post">
        <input id="telephone" type="text" name="telephone" value="${uv.telephone}"
        placeholder="请输入手机号">
        <select id="deptid" name="dept.id">
            <option value="0">--请选择部门--</option>
            <option value="1" ${uv.dept.id==1?"selected":""}>技术部</option>
            <option value="2" ${uv.dept.id==2?"selected":""}>市场部</option>
            <option value="3" ${uv.dept.id==3?"selected":""}>销售部</option>
        </select>
        <input id="available"  type="text" name="available" value="${uv.available}"
        placeholder="请输入状态0/1">
        <input type="submit" value="搜索">
    </form>
    <a href="${pageContext.request.contextPath}/user/goAddUser">增加用户</a>
    <tr>
        <td>编号</td>
        <td>手机号</td>
        <td>密码</td>
        <td>姓名</td>
        <td>生日</td>
        <td>头像</td>
        <td>状态</td>
        <td>部门</td>
    </tr>
    <c:forEach var="user" items="${userlist}">
        <tr>
            <td>${user.id}</td>
            <td>${user.telephone}</td>
            <td>${user.password}</td>
            <td>${user.realname}</td>
            <td><fmt:formatDate value="${user.birthday}" pattern="yyyy-MM-dd"></fmt:formatDate></td>
            <td> <img src="${pageContext.request.contextPath}${user.headimg}" width="50px" height="50px"> </td>
            <td>${user.available==1?"正常":"禁用"}</td>
            <td>${user.dept.dname}</td>
        </tr>
    </c:forEach>
</table>
<div>
    <ul>
        <li><a href="javascript:goPage(${uv.pageSize-1})">上一页</a></li>
        <li><a href="javascript:goPage(${uv.pageSize+1})">下一页</a></li>
    </ul>
</div>
</body>
</html>
